package com.aya.transaction;

import com.aya.transaction.service.BlogNotSupportedTransactionService;
import com.aya.transaction.service.BlogSupportsTransactionService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * 事物异常回滚
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringTransaction.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SupportedTransaction {

    @Resource
    BlogSupportsTransactionService blogSupportsTransactionService;

    @Test
    public void testSuccess() {
        blogSupportsTransactionService.updateByIdSuccess("1", "transaction success","2","success");
    }
    @Test
    public void testFailure() {
        blogSupportsTransactionService.updateByIdInnerFailure("1", "transaction success","2","not support failure");
    }

    @Test
    public void testCatchFailure() {
        blogSupportsTransactionService.updateByIdCatchFailure("1", "transaction success","2","not support failure");
    }

    @Test
    public void testOuterSuccess() {
        blogSupportsTransactionService.updateByIdOuterSuccess("1", "transaction success","2","success");
    }
    @Test
    public void testOuterFailure() {
        blogSupportsTransactionService.updateByIdOuterFailure("1", "transaction success","2","not support failure");
    }

}
